<template>
  <div class="app-container">
    <!-- 查询参数表单 -->
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" label-width="68px">
       
        
          <el-form-item label="机型" prop="model">
            <el-input v-model.trim="queryParams.model" @input="onInputChange1($event)" placeholder="请输入机型" clearable
              @keyup.enter.native="handleQuery" />
          </el-form-item>
           
        <el-form-item label="bug编码" prop="bugCode">
          <el-input v-model="queryParams.bugCode" @input="inputOnchange1($event)" placeholder="请输入bug编码" clearable
            @keyup.enter.native="handleQuery" />
        </el-form-item>
          
        <el-form-item label="创建人" prop="createUserName">
          <el-input v-model="queryParams.createUserName" @input="inputOnchange12($event)" placeholder="请输入bug创建人"
            clearable @keyup.enter.native="handleQuery" />
        </el-form-item>
      

      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>  
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
        
      </el-form-item>
    </el-form>
 


    <!-- 导航菜单 -->
    <el-row class="mb8" v-show="!addBug">
       
      <el-menu :default-active="activeIndex1" class="el-menu-demo" mode="horizontal" @select="handleSelect"
        text-color="#000000" active-text-color="#ffd04b"> 
        <el-menu-item index="3">
          <el-badge :value="waitCount" class="item">
            待处理
          </el-badge>
        </el-menu-item>
        <template>
          <el-menu-item index="5">已处理</el-menu-item>
        </template>
      </el-menu>
    </el-row>

   
    <el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport"
      v-hasPermi="['business:bugs:gysExportBugs']">导出</el-button>
   
    <right-toolbar :columns="columns2" :search="false" @queryTable="resetQuery" :isCallback="true"
      @callBack="updateTableColum"></right-toolbar>

    <vxe-table border :loading="loading" :data="bugsList" :scroll-y="{ enabled: false }" keep-source
      :keyboard-config="{ isArrow: true }" :row-style="rowStyle"
      :edit-config="{ trigger: 'click', mode: 'row', showStatus: true, autoClear: false }"
      :column-config="{ useKey: true, resizable: true }" :row-config="{ useKey: true }" :edit-rules="validRules"
      ref="bugTable" @checkbox-change="selectChangeEvent" @checkbox-all="selectChangeEvent"
      @cell-dblclick="cellClickEvent" @edit-actived="editActivedEvent"
      :checkbox-config="{ checkMethod: checCheckboxkMethod }"> 
      <vxe-column field="model" title="机型"   width="100">
        <template #edit="{ row }">
          <vxe-input v-model="row.model" type="text"></vxe-input>
        </template>
      </vxe-column>
      <vxe-column field="bugCode" title="BUG编码"   width="100">
        <template #edit="{ row }">
          <vxe-input v-model="row.bugCode" type="text"></vxe-input>
        </template>
      </vxe-column>
      <vxe-column field="problemType" title="问题类别"   width="100">
        <template #edit="{ row }">
          <vxe-input v-model="row.problemType" type="text"></vxe-input>
        </template>
      </vxe-column>
      <vxe-column field="level" title="严重程度" width="100">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.problem_level" :value="scope.row.level" />
        </template>
      </vxe-column>
      <vxe-column field="bugTitle" title="BUG标题"   width="100">
        <template #edit="{ row }">
          <vxe-input v-model="row.bugTitle" type="text"></vxe-input>
        </template>
      </vxe-column>
      <vxe-column field="descriptions" type="html" title="bug描述" width="250">
        <template #edit="{ row }">
          <span v-html="row.descriptions"></span>
        </template>
      </vxe-column>
      <vxe-column field="bugVersion" title="FW版本"   width="100">
        <template #edit="{ row }">
          <vxe-input v-model="row.bugVersion" type="text"></vxe-input>
        </template>
      </vxe-column>
      
      <vxe-column field="respon" title="责任人"   width="100">
        <template #edit="{ row }">
          <vxe-input v-model="row.respon" type="text"></vxe-input>
        </template>
      </vxe-column>
        
      <vxe-column field="analysis" title="bug分析" :edit-render="{ autofocus: '.vxe-input--inner' }" width="250">
        <template #edit="{ row }">
          <vxe-textarea v-model="row.analysis" :disabled="showHandleStatus1" placeholder="请输入bug分析"
            show-word-count></vxe-textarea>
        </template>
      </vxe-column>
      <vxe-column field="answer" title="改善对策" :edit-render="{ autofocus: '.vxe-input--inner' }" width="250">
        <template #edit="{ row }">
          <vxe-textarea v-model="row.answer" :disabled="showHandleStatus1" placeholder="请输入改善对策"
            show-word-count></vxe-textarea>
        </template>
      </vxe-column> 
      
      <vxe-column field="answerTime" title="改善时间"   width="100">
        <template #edit="{ row }">
          <vxe-input v-model="row.answerTime" type="text"></vxe-input>
        </template>
      </vxe-column>
      <vxe-column field="createUserName" :visible="false" title="创建人" width="100">
        <template #edit="{ row }">
          <vxe-input v-model="row.createUserName" type="text" placeholder=""></vxe-input>
        </template>
      </vxe-column>
        

      <vxe-column title="操作" fixed="right" width="58">
        <template #default="{ row }">
          <div>
            <div v-if="$refs.bugTable.isActiveByRow(row)">
              
              <div v-if="activeIndex1 == '3' || activeIndex1 == '4'">
                <vxe-button size="mini" status="success" v-hasPermi="['business:bugs:handle']" v-if="saveButton"
                  @click="saveRowEvent(row)">保存</vxe-button>

                  <vxe-button size="mini" status="success" v-hasPermi="['business:bugs:handle']" v-if="saveButton"
                  @click="handleTransfer(row)">转办</vxe-button>
              </div>
              

              <div>
                <vxe-button size="mini" status="warning" @click="cancelRowEvent(row)">取消</vxe-button>
              </div>
            </div>
            <div style="text-align: center;" v-if="!$refs.bugTable.isActiveByRow(row)">
              
         
              
            </div>
            <div>
              <vxe-button status="primary" size="mini" @click="handleDrawerOpen(row)">历史</vxe-button>
            </div>
           
          </div>
        </template>
      </vxe-column>
    </vxe-table>

    <!-- 分页 -->
    <vxe-pager border size="medium" :loading="loading" :current-page="queryParams.pageNum"
      :page-size="queryParams.pageSize" :total="total"
      :layouts="['PrevPage', 'JumpNumber', 'NextPage', 'FullJump', 'Sizes', 'Total']" @page-change="handlePageChange2">
    </vxe-pager>
 
    <!-- 历史处理记录 -->
    <BugHandleHistory ref="bugHandleHistor" />


    <el-dialog :close-on-click-modal="false" :title="title" :visible.sync="open" @close="cancel" width="400px"
    append-to-body>
    <el-form ref="form" :model="form" :rules="rules" label-width="80px">
      <el-form-item label="转办人" prop="rdHandle">
        <el-select filterable multiple clearable v-model="form.rdHandle" placeholder="请选择指派人">
          <el-option v-for="item in rdHandleList" :key="item.userId" :label="item.nickName"
            :value="item.userId"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="转办原因" prop="reason">
        <el-input v-model="form.reason" type="textarea" placeholder="请输入转办原因"></el-input>
      </el-form-item>
    </el-form>
    <div slot="footer" class="dialog-footer" v-show="buttonView">
      <el-button type="primary" @click="submitForm">确 定</el-button>
      <el-button @click="cancel">取 消</el-button>
    </div>
  </el-dialog>
  
  </div>
</template>

<script>
import { listBugsGys,  delBugs,   handleBugs, closeBugs, waiveBugs, transferBug, resetBugs, activationBugs } from "@/api/business/bugs"
import { getProjectDetail } from "@/api/business/project"
import {   getUsersByRolekey } from "@/api/system/user"
import { updateAnalysis } from "@/api/business/analysis"
import router from "../../../router"
import Copy from "@/components/business/bugs/Copy"
import importFileLog from "@/components/importFileLog/index"
import BugHandleHistory from "@/components/business/bugs/BugHandleHistory"
import ApproverWaive from "@/components/business/bugs/ApproverWaive.vue"
export default {
  name: "supplierBug",
  components: { router, Copy, BugHandleHistory, importFileLog, ApproverWaive },
  dicts: ['bugs_status', 'problem_level', 'problem_type'],
  data() {
    return {
      npiName: null,//NPI角色登录的名称
      cupdateFlag: false,//关闭还能修改的权限
      columns2: [],
      RD: false,
      NPI: false,
      dialogVisible:false,//转办弹框
      collapsable1: false,
      collapsable2: false,
      collapsable3: false,
      scrollFlag: "scroll",//设置滚动条位置标记
      projectFlage: null,
      waitCount: null,
      view: false,
      saveButton: true,//控制保存按钮的显示
      showHandleStatus0: false,
      showHandleStatus1: false,
      addBug: false,//根据项目状态判断是否可以创建bug
      buttonView: true,
      rdHandleList: [],
      activeIndex1: '3',
      //项目id
      pid: null,
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: false,
      // 总条数
      total: 0,
      // 项目bugs列表格数据
      bugsList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 5,
        pid: null,
        bugCode: null,
        problemType: null,
        identify: null,
        level: null,
        modelCode: null,
        badPersentage: null,
        bugTitle: null,
        bugVersion: null,
        exceptionType: null,
        exceptionCode: null,
        respon: null,
        rdHandle: null,
        bugStatus: null,
        handleStatus: null,
        param: null,
        model: null,
        projectNo: null,
        chipGroup: null,
        adBoard: null,
        lcmOc: null,
        powerSupply: null,
        powerSuppleId: null,
        lcmOcId: null,
      },
      //项目信息表单
      projectForm: { custom: null },
      // 表单参数
      form: { rdHandle: [], reason: null },
      // vxe-table 表格验证
      validRules: {
        analysis: [
          { required: true, message: 'bug分析分析不能为空' },
        ],
        answer: [
          { required: true, message: '改善对策不能为空' }
        ],
        newDescriptions: [{ required: true, message: '请输入描述', trigger: 'blur' }],
        bugVersion: [{ required: true, message: '请输入处理/验证版本', trigger: 'blur' }],
        rdHandle: [{ required: true, message: '请选择研发指派人', trigger: 'blur' }],
        bugStatus: [{ required: true, message: '请选择bug状态', trigger: 'blur' }],
        problemType: [{ required: true, message: '请选择问题类别', trigger: 'blur' }],
      },
      
    };
  },
  computed: {
    getIcon() {
      return this.showSearch ? 'el-icon-arrow-up' : 'el-icon-arrow-down';
    }
  },
  watch: {
    $route: 'init',
    // 深度观察监听
    deep: true,
  },
  mounted() {
   
    this.initColums()
  },
  befordestroed() {
    clearTimeout(this.timer)
  },
  created() {
 
    //获取登录名称
    this.loginName = this.$store.getters.name
    this.init();
  },
  methods: {
    updateTable() {
      this.getList()
      this.getWaitCount()
    },




    /**
     * 研发申请waive单
     * @param {*} row 
     */
    handleApproverWaive(row) { 
      this.$refs.approverwaive.openLog(row.id)
    },
    updateTableColum(data) {
      // console.log(data)
      if (this.$refs.bugTable) {
        this.$refs.bugTable.refreshColumn()
      }
    },
    //初始化表格显示的字段
    initColums() {
      this.$nextTick(() => {
        this.columns2 = this.$refs.bugTable.getColumns()
        // console.log(this.columns2)
        this.columns2 = this.columns2.filter(item => {
          return item.field && item.field != 'projectNo' && item.field != 'bugCode'
            && item.field != 'bugStatus' && item.field != 'bugStatus' && item.field != 'bugVersion'
            && item.field != 'analysis' && item.field != 'answer' && item.field != 'rdHandle' && item.field != 'problemType'
        })
        for (let item of this.columns2) {
          item.label = item.title
        }
      })
    },
    //单元格点击展开/显示隐藏字段
    cellClickEvent({ column }) {
      // console.log(column)
      if (column.field && column.field == 'projectNo') {
        this.collapsable1Event()
      } else if (column.field && column.field == 'bugCode') {
        this.collapsable2Event()
      }
    },
    //隐藏/显示字段点击事件
    collapsable1Event() {
      const fields = ['model', 'chipGroup', 'adBoard', 'lcmOc', 'powerSupply']
      this.collapsable1 = !this.collapsable1
      const bugTable = this.$refs.bugTable
      fields.forEach(field => {
        const column = bugTable.getColumnByField(field)
        column.visible = this.collapsable1
      })
      bugTable.refreshColumn()
      this.initColums()
    },
    collapsable2Event() {
      const fields = ['createUserName', 'createTime', 'lcmOcId', 'powerSuppleId', 'powerSupply']
      this.collapsable2 = !this.collapsable2
      const bugTable = this.$refs.bugTable
      fields.forEach(field => {
        const column = bugTable.getColumnByField(field)
        column.visible = this.collapsable2
      })
      bugTable.refreshColumn()
      this.initColums()
    },
    collapsable3Event() {
      const fields = ['modelCode', 'badPersentage']
      this.collapsable3 = !this.collapsable3
      const bugTable = this.$refs.bugTable
      fields.forEach(field => {
        const column = bugTable.getColumnByField(field)
        column.visible = this.collapsable3
      })
      bugTable.refreshColumn()
    },
    //批量导入bug数据
    handleImport() {
      this.$refs.importFileLog.onOpen()
    },
    //获取待处理的bug数量
    getWaitCount() {
      let param = {
        pageNum: 1,
        pageSize: 10,
        queryKey: '3'
      }
      if (this.pid) {
        param.pid = this.pid
      }
      listBugsGys(param).then(response => {
        this.waitCount = response.total == 0 ? null : response.total;
      });
    },
    init() {


      // else{//不是从项目清单跳转过来的，默认在待处理栏
      this.queryParams.queryKey = this.activeIndex1
      // }
      //首页待处理数据路由跳转带过来的code
      const bugCode = this.$route.query.code;
      if (bugCode) {
        this.queryParams.bugCode = bugCode;
      }
      this.getList();
      this.getRdHandleList()
      this.getWaitCount();
    },
    //表格数据行样式
    rowStyle({ rowIndex, row }) {
      if (row.bugStatus == '40') {//关闭状态的bug置灰色
        return {
          backgroundColor: '#e0e0e0',
        }
      }
    },
    //查看bug处理详情
    handleDrawerOpen(row) {
      this.$refs.bugHandleHistor.open(row.id)
    },
    //状态修改事件
    changeBugStatus(param, row) {
      // console.log(param, row);
      if (param.value === '40') {//关闭
        this.validRules.newDescriptions[0].required = false
        this.validRules.rdHandle[0].required = false
        this.validRules.problemType[0].required = false
      } else {//如果不是关闭
        this.validRules.newDescriptions[0].required = true
        this.validRules.rdHandle[0].required = true
        this.validRules.problemType[0].required = true
      }
    },
    // 编辑触发事件
    editActivedEvent({ rowIndex, row }) { 
       
      if (row.bugStatus === '40' || row.bugStatus === '30') {//关闭或者是waive
        this.saveButton = false

        this.showHandleStatus0 = true
        this.showHandleStatus1 = true
      } else {//判断编辑字段是否必填
        this.saveButton = true

        if (this.activeIndex1 == '5') {//已处理页面修改的编辑字段为分析与对策（只针对研发）
          this.showHandleStatus0 = true
          this.showHandleStatus1 = false
          this.validRules.newDescriptions[0].required = false
          this.validRules.rdHandle[0].required = false
          this.validRules.problemType[0].required = false
          this.validRules.bugStatus[0].required = false
          this.validRules.bugVersion[0].required = false

          this.validRules.analysis[0].required = true
          this.validRules.answer[0].required = true
        } else {//其他栏目
          row.bugStatus = ''
          if (row.handleStatus === '0') {//工程师
            row.bugVersion = ''
            this.showHandleStatus0 = true
            this.showHandleStatus1 = false
            this.validRules.newDescriptions[0].required = false
            this.validRules.rdHandle[0].required = false
            this.validRules.problemType[0].required = false
            this.validRules.bugStatus[0].required = false

            this.validRules.analysis[0].required = true
            this.validRules.answer[0].required = true
          } else if (row.handleStatus == '1') {//品质
            this.showHandleStatus1 = true
            this.showHandleStatus0 = false
            row.problemType = ''
            this.validRules.analysis[0].required = false
            this.validRules.answer[0].required = false

            this.validRules.newDescriptions[0].required = true
            this.validRules.rdHandle[0].required = true
            this.validRules.problemType[0].required = true
            this.validRules.bugStatus[0].required = true
          }
        }

      }
      
    },
    //编辑保存方法
    async saveRowEvent(row) {
      this.$modal.loading("正在处理请稍等....")
      const $table = this.$refs.bugTable
      //校验参数不能为空
      const errMap = await $table.validate(row)
      if (errMap) {
        this.$modal.msgError('请填写必填项')
        this.$modal.closeLoading()
        return
      }
      //处理函数
      handleBugs(row).then(result => {
        this.$modal.closeLoading()
        this.loading = false
        $table.clearActived().then(() => {
          this.$modal.msgSuccess(result.msg)
          this.queryParams.bugCode = null
          this.getList()
          this.getWaitCount()
        })
      }).catch(() => {
        this.$modal.closeLoading()
      })

    },
    //编辑修改方法
    async updateRowEvent(row) {
      this.$modal.loading("正在处理请稍等....")
      const $table = this.$refs.bugTable
      //校验参数不能为空
      const errMap = await $table.validate(row)
      if (errMap) {
        this.$modal.msgError('请填写必填项')
        this.$modal.closeLoading()
        return
      }
      // console.log(row);
      let param = {}
      param.id = row.baid
      param.analysis = row.analysis
      param.bugAnswer = row.answer
      param.bugId = row.id
      //执行修改
      updateAnalysis(param).then(res => {
        this.$modal.closeLoading()
        this.loading = false
        $table.clearActived().then(() => {
          this.$modal.msgSuccess(res.msg)
          this.getList()
        })
      }).catch(() => {
        this.$modal.closeLoading()
      })
    },
    //取消保存函数
    cancelRowEvent(row) {
      const $table = this.$refs.bugTable
      $table.clearActived().then(() => {
        // 还原行数据
        // $table.revertData(row)
        //刷新数据
        this.getList()
      })
      this.clearSelection()
    },
    //多选禁止勾选
    checCheckboxkMethod({ row }) {
      if (this.activeIndex1 == '5') {//已处理页面不能勾选多选框
        return false
      } else {
        if (row.bugStatus == 30 || row.bugStatus == 40) {
          return false
        } else {
          return true
        }
      }

    },
    //多选框选择时件
    selectChangeEvent({ checked }) {
      const records = this.$refs.bugTable.getCheckboxRecords()
      this.ids = records.map(item => item.id);
      // this.single = records.length !== 1;
      this.multiple = !this.ids.length
      this.queryParams.ids = this.ids
    },
    //分页方法
    handlePageChange2({ currentPage, pageSize }) {
      this.queryParams.pageNum = currentPage
      this.queryParams.pageSize = pageSize
      this.getList()
    },
    //bug状态转义
    formatBugStatus(status) {
      if (status == 0) {
        return "Pendding";
      } else if (status == 10) {
        return "Open";
      } else if (status == 20) {
        return "Tracking";
      } else if (status == 30) {
        return "Waive";
      } else if (status == 40) {
        return "Close";
      }
      return "";
    },
    /**
     * 激活已关闭的bug
     * @param {*} row
     */
    handleActivation(row) {
      const id = row.id
      this.$modal.confirm('是否确认重新激活bug编码为:' + row.bugCode + '的数据项？').then(function () {
        return activationBugs(id);
      }).then(
        response => {
          this.getList();
          this.$modal.msgSuccess(response.msg);
        }
      ).catch(() => { });
    },
    /**
     * 复制按钮
     * @param {*} row
     */
    handleCopy(row) {
      const id = row.id
      this.$refs.copy.onOpen(id)
    },
    /**
     * 获取指派人列表
    */
    getRdHandleList() {
      let rdList = []
      let npiList = []
      getUsersByRolekey(this.$store.state.globalParam.RDROLE).then(result => {
        rdList = result.data
        getUsersByRolekey(this.$store.state.globalParam.NPI).then(result => {
          npiList = result.data
          this.rdHandleList = rdList.concat(npiList)
        })

      })
    },
    handleTransfer(row) {
      this.reset()
      if (row.id) {
        this.title = "bug转办"
      } else {
        this.title = "bug批量转办"
      }
      this.open = true
      this.form.id = row.id
      this.form.ids = this.ids
    },
    paramChange(event) {
      this.queryParams.bugCode = null
      this.queryParams.param = event
      this.getList()
    },
    //判断数据是否可以被多选
    selectable(row, index) {
      if (row.bugStatus == 30 || row.bugStatus == 40) {
        return false
      } else {
        return true
      }
    },
    //清除多选数据
    clearSelection() {
      // this.$refs.bugTable.clearSelection();
      if (Array.from(this.ids).length > 0) {
        this.$refs.bugTable.clearCheckboxRow()
        this.ids = []
        this.multiple = !this.ids.length
      }
    },
    //回显id
    getRowKey(row) {
      return row.id
    },
    //导航菜单选择触发事件
    handleSelect(key, keyPath) {
      // console.log(key, keyPath);
      // if(key == '1'){//全部
      // }else if(key == '2'){//未关闭
      //   this.queryParams.queryKey = key
      // }else if(key == '3'){//指派给我的
      //   this.queryParams.queryKey = key
      // }else if(key == '4'){//我创建的
      //   this.queryParams.queryKey = key
      // }
      this.queryParams.queryKey = key
      this.activeIndex1 = key
      this.getList()
    },
    getProjectFormDate(id) {
      getProjectDetail(id).then(result => {
        if (result.data) {
          this.projectForm = result.data;
          const projectStatus = result.data.status;
          if (projectStatus == 20 || projectStatus == 30) {//关闭状态不允许创建bug
            this.addBug = true
          }
        }
      });
    },
    //高级搜索、收起点击事件
    Qquery() {
      this.queryParams = {
        pageNum: 1,
        pageSize: 5,
        pid: null,
        bugCode: null,
        problemType: null,
        identify: null,
        level: null,
        modelCode: null,
        badPersentage: null,
        bugTitle: null,
        bugVersion: null,
        exceptionType: null,
        exceptionCode: null,
        respon: null,
        rdHandle: null,
        bugStatus: null,
        handleStatus: null,
        param: null,
        model: null,
        projectNo: null,
        chipGroup: null,
        adBoard: null,
        lcmOc: null,
        powerSupply: null,
        powerSuppleId: null,
        lcmOcId: null,
      }
      this.queryParams.queryKey = this.activeIndex1
      this.queryParams.pid = this.pid
      this.getList()
      this.showSearch = !this.showSearch;
    },
    /** 查询项目bugs列列表 */
    getList() {
      this.loading = true;
      // console.log(this.queryParams,"查询条件");
      listBugsGys(this.queryParams).then(response => {
        this.bugsList = response.rows;
        // console.log(response,"更新了");
        this.total = response.total;
        this.loading = false;
        //设置滚动条位置
        // setTimeout(() => {
        //   this.$refs.bugTable.scrollTo(730, 0)
        // }, 100)
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        ids: [],
        rdHandle: [],
      };
      this.resetForm("queryForm");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.queryParams = {
        pageNum: 1,
        pageSize: 5,
        pid: null,
        bugCode: null,
        problemType: null,
        identify: null,
        level: null,
        modelCode: null,
        badPersentage: null,
        bugTitle: null,
        bugVersion: null,
        exceptionType: null,
        exceptionCode: null,
        respon: null,
        rdHandle: null,
        bugStatus: null,
        handleStatus: null,
        param: null,
        model: null,
        projectNo: null,
        chipGroup: null,
        adBoard: null,
        lcmOc: null,
        powerSupply: null,
        powerSuppleId: null,
        lcmOcId: null,
      }
      this.queryParams.queryKey = this.activeIndex1
      this.queryParams.pid = this.pid
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id);
      // this.single = selection.length !== 1;
      this.multiple = !selection.length;
    },
    /** 新增按钮操作 */
    handleAdd() {
      //关闭当前页面
      this.$store.dispatch("tagsView/delView", this.$route);
      this.$nextTick(() => {
        this.$router.push({
          name: 'BugsForm',
          query: {
            pid: this.pid
          }
        });
      });
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.$nextTick(() => {
        this.$router.push({
          name: 'updateBug',
          query: {
            id: row.id,
            upPid: this.pid
          }
        })
      })
    },
    /** 转办提交按钮 */
    submitForm() {
      this.buttonView = false
      this.$refs["form"].validate(valid => {
        if (valid) {
          this.$modal.loading("正在处理请稍等....")
          transferBug(this.form).then(response => {
            this.$modal.msgSuccess(response.msg);
            this.open = false;
            this.getList();
            this.$modal.closeLoading()
            if (this.form.ids) {
              this.clearSelection()
            }
            this.getWaitCount();
          });
          this.$modal.closeLoading()
        }
        this.buttonView = true
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$modal.confirm('是否确认删除bug编号为"' + row.bugCode + '"的数据项？').then(function () {
        return delBugs(ids);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => { });
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('business/bugs/gysExportBugs', {
        ...this.queryParams
      }, `bugs_${new Date().getTime()}.xlsx`);
    },
    /**
     * 重置wavie 状态的bug
     * @param {*} row
     */
    handleReset(row) {
      const id = row.id
      this.$modal.confirm('是否确认重置bug编码为:' + row.bugCode + '的数据项？').then(function () {
        return resetBugs(id);
      }).then(
        response => {
          this.getList();
          this.$modal.msgSuccess(response.msg);
        }
      ).catch(() => { });
    },
    /**
     * 关闭bug
     * @param {*} row
     */
    handleClose(row) {
      const id = row.id
      const ids = this.ids
      let param = {}
      param.id = id
      param.ids = ids
      this.$modal.confirm('是否确认关闭所选的数据项？').then(function () {
        return closeBugs(param);
      }).then(
        response => {
          this.getList();
          this.$modal.msgSuccess("关闭成功");
          if (this.ids) {
            this.clearSelection()
          }
        }
      ).catch(() => { });
    },
    handleWaive(row) {
      const id = row.id
      const ids = this.ids
      let param = {}
      param.id = id
      param.ids = ids
      this.$modal.confirm('是否确认Waive所选的数据项？').then(function () {
        return waiveBugs(param);
      }).then(
        response => {
          this.getList();
          this.$modal.msgSuccess("Waive成功");
          if (this.ids) {
            this.clearSelection()
          }
        }
      ).catch(() => { });
    },
    inputOnchange1(event) {
      this.queryParams.bugCode = event
      this.getList()
    },
    inputOnchange2(event) {
      this.queryParams.identify = event
      this.getList()
    },
    inputOnchange3(event) {
      this.queryParams.level = event
      this.getList()
    },
    inputOnchange4(event) {
      this.queryParams.modelCode = event
      this.getList()
    },
    inputOnchange5(event) {
      this.queryParams.badPersentage = event
      this.getList()
    },
    inputOnchange6(event) {
      this.queryParams.bugTitle = event
      this.getList()
    },
    inputOnchange7(event) {
      this.queryParams.bugVersion = event
      this.getList()
    },
    inputOnchange8(event) {
      this.queryParams.exceptionCode = event
      this.getList()
    },
    inputOnchange9(event) {
      this.queryParams.respon = event
      this.getList()
    },
    inputOnchange10(event) {
      this.queryParams.powerSuppleId = event
      this.getList()
    },
    inputOnchange11(event) {
      this.queryParams.lcmOcId = event
      this.getList()
    },
    inputOnchange12(event) {
      this.queryParams.createUserName = event
      this.getList()
    },
    onInputChange1(event) {
      this.queryParams.model = event
      this.getList()
    },
    onInputChange2(event) {
      this.queryParams.projectNo = event
      this.getList()
    },
    onInputChange3(event) {
      this.queryParams.chipGroup = event
      this.getList()
    },
    onInputChange4(event) {
      this.queryParams.adBoard = event
      this.getList()
    },
    onInputChange5(event) {
      this.queryParams.lcmOc = event
      this.getList()
    },
    onInputChange6(event) {
      this.queryParams.powerSupply = event
      this.getList()
    },
    selectChange(event) {
      this.queryParams.bugStatus = event
      this.getList()
    },
  },

};
</script>
<style lang="scss" scoped>
.el-col {
  height: 50px;
}

.labelword ::v-deep .el-form-item__label {
  white-space: pre-line !important;
  line-height: 15px !important;
}
</style>
